import { getNowFormatDate } from '@/utils/time';
import { FieldTimeOutlined } from '@ant-design/icons';
import React, { Component } from 'react';

var NowTimeDateTimer = null;
export default class HanderTime extends Component {
  state = {
    time: null,
  };
  componentDidMount() {
    NowTimeDateTimer = setInterval(() => {
      this.setState({ time: getNowFormatDate() });
    }, 1000);
  }

  //定时器销毁
  componentWillUnmount() {
    clearInterval(NowTimeDateTimer);
    NowTimeDateTimer = null;
  }
  render() {
    return (
      <div>
        <FieldTimeOutlined size={2} style={{ marginRight: '5px' }} />
        {this.state.time}
      </div>
    );
  }
}
